package games.gameObjects.invaders;

import pt.iul.poo.image.MovingImage;
import gameUtils.Coordinate;
import games.Main;
import games.gameObjects.MovingTDObject;
import games.gameObjects.MovementType;

/**
 * 
 * @author batata
 *
 *	Class that represents the invaders
 * 	Base class for all kind of invaders
 */
public abstract class Invader extends MovingTDObject{

	public static final String TD_CLASS = "Invader";
	private int healthpoints, value;

	public Invader(final Coordinate coordinate, final int priority, final int healthpoints, final int value){
		super(coordinate, priority);

		this.healthpoints = healthpoints;
		this.value = value;
	}


	@Override
	public void setCoordinate(final int x, final int y) {
		MovingImage img = (MovingImage) getImage();

		img.move((int)((x - getCoordinate().getAbcissa()) * Main.SQUARE_DIMENSION.getWidth()), 
				(int)((y - getCoordinate().getOrdinate()) * Main.SQUARE_DIMENSION.getHeight()));

		super.setCoordinate(x, y);
	}


	/**
	 * Function that returns the current health points of the mob
	 * @return int - the Invader health points
	 */
	public int getHealthpoints() {
		return healthpoints;
	}


	/**
	 * Function that returns how much is the value of the invader
	 * @return int - the value of the invader
	 */
	public int getValue() {
		return value;
	}

	/**
	 * String representation of the Invader
	 */
	public String toString(){
		return "HP:"+healthpoints+"\n" +
				"value:"+value;
	}
	/**
	 * Function that returns what type of movement
	 * the Invader have: {PEDESTRIAN, AERIAL, AQUATIC}
	 */
	public abstract MovementType getMovementType();


	@Override
	public String getTDClass() {
		return TD_CLASS;
	}

	public void setHealthPoints(final int towerDamage) {
		this.healthpoints -= towerDamage;
	}

	/**
	 * Tester Invader
	 * @param args
	 */
	//	public static void main(String[] args) {
	//
	//		Bug b = new Bug(new Coordinate(1,2),2);
	//		Dragon d = new Dragon(new Coordinate(1,2),1);
	//
	//		System.out.println(d.getCoordinate());
	//		d.flyTo(new Coordinate(5,4));
	//
	//		System.out.println(b);
	//		System.out.println(d.getCoordinate());
	//	}

}
